package newWork.service.impl;

import newWork.dao.IProjectDao;
import newWork.entity.ProjectEntity;
import newWork.service.IProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

@Service
public class ProjectService implements IProjectService {


    private IProjectDao dao;

    @Autowired
    public ProjectService(IProjectDao dao) {
        this.dao = dao;
    }

    @Override
    public void add(ProjectEntity entity) {
        //计算总价
        BigDecimal total = new BigDecimal(0);
        total = total.add(entity.getModelPrice()).add(entity.getRenderPrice()).add(entity.getLastPrice());
        entity.setProjectTotalPrice(total);
        //设置初始状态 未完成
        entity.setProjectState(0);
        //进度 第一步
        entity.setProjectStepState(1);
        dao.add(entity);
    }

    @Override
    public void delete(ProjectEntity entity) {
        dao.delete(entity);
    }

    @Override
    public void update(ProjectEntity entity) {
        dao.update(entity);
    }

    @Override
    public List<ProjectEntity> select(ProjectEntity entity) {
        return dao.select(entity);
    }

    @Override
    public Long likeSelectCount(ProjectEntity entity) {
        return dao.likeSelectCount(entity);
    }

}
